import OutPut, Search
from testinput import test_if_int2


# 修改信息的代码，将整个数据传入后根据所给下标进行修改并返回新的数据
def ModifyFunction(main_list, index):
    # 显示将要修改的数据原状
    OutPut.OutPutFunctionSmall(main_list[index])
    print("1.修改学号")
    print("2.修改姓名")
    print("3.修改年龄")
    print("4.修改性别")
    print("0.退出修改")
    choice, judge = test_if_int2.test_if_int_function(input("请选择要更改的数据:>"))
    if judge:
        if choice == 1:
            main_list[index][0] = input("请输入修改后的学号")
        elif choice == 2:
            main_list[index][1] = input("请输入修改后的姓名")
        elif choice == 3:
            temp, judge = test_if_int2.test_if_int_function(input("请输入修改后的年龄"))
            if judge:
                main_list[index][2] = temp
        elif choice == 4:
            main_list[index][3] = input("请输入修改后的性别")
        elif choice == 0:
            None
        else:
            print("你选择了未知选项，请重新选择业务")
    else:
        print("修改失败")
    return main_list


if __name__ == '__main__':
    test_list = [['a','b','c','d'],['a','b','c','d']]
    test_list = ModifyFunction(test_list,1)
    print(test_list)